home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / FPSE_src / include / sio.h < prev    next >
C/C++ Source or Header  |  2000-01-01  |  3KB  |  108 lines

  1. #ifndef SIO_H
  2. #define SIO_H
  3.  
  4. /* FIFO size in SIO */
  5. #define MAXIOBUF                8
  6.  
  7. /* Status Reg bits */
  8. #define TX_RDY                  0x0001
  9. #define RX_RDY                  0x0002
  10. #define TX_EMPTY                0x0004
  11. #define PE                      0x0008
  12. #define RX_OVERRUN              0x0010
  13. #define FE                      0x0020
  14. #define SYNCDET                 0x0040
  15. #define DSR                     0x0080
  16. #define CTS                     0x0100
  17. #define SIO_IRQ                 0x0200
  18.  
  19. /* Mode Reg bits */
  20. #define PRESCALER1              0x0001
  21. #define PRESCALER16             0x0002
  22. #define PRESCALER64             0x0003
  23. #define BYTE5BIT                0x0000
  24. #define BYTE6BIT                0x0004
  25. #define BYTE7BIT                0x0008
  26. #define BYTE8BIT                0x000C
  27. #define PARITY                  0x0010
  28. #define PARITY_ODDEVEN          0x0020
  29. #define STOP1BIT                0x0040
  30. #define STOP15BIT               0x0080
  31. #define STOP2BIT                0x00C0
  32.  
  33. /* Control Reg bits */
  34. #define TxENABLE                0x01
  35. #define DTR                     0x02
  36. #define RxENABLE                0x04
  37. #define CHNBREAK                0x08
  38. #define ERROR_RESET             0x10
  39. #define RTS                     0x20
  40. #define INTERNAL_RESET          0x40
  41. #define HUNT_MODE               0x80
  42.  
  43. /* Interrupt Reg bits */
  44. #define BUFFERSIZE              0x03
  45. #define TxIRQ                   0x04
  46. #define RxIRQ                   0x08
  47. #define DSRIRQ                  0x10
  48. #define CTSIRQ                  0x20 // Not sure about this
  49.  
  50. /* SIO clock speed */
  51. #define SIOBAUDCLOCK            0x001FA400
  52.  
  53. // SIO IRQ handling
  54. #define SIO_IRQ_NONE    0
  55. #define SIO_IRQ_IMM     1
  56. #define SIO_IRQ_ASYNC   2
  57. #define SIO_IRQ_VSYNC   3
  58.  
  59. /* SIO emulation struct */
  60. typedef struct {
  61.     UINT8  RxBuf[MAXIOBUF];
  62.     UINT8  TxBuf[MAXIOBUF];
  63.     int    RxNum,TxNum;
  64.     int    RxStart,RxEnd;
  65.     UINT32 Status;
  66.     UINT16 Mode;
  67.     union {
  68.         struct {
  69. #ifdef MSB_FIRST
  70.             UINT8  Irq, Line;
  71. #else
  72.             UINT8  Line, Irq;
  73. #endif
  74.         } Control8;
  75.         UINT16 Control16;
  76.     } Ctrl;
  77.     UINT32 Baud;
  78.     int    FifoSize;
  79.     int    IrqLevel;
  80.     int    IrqSrc;
  81.     int    IrqFlags;
  82.     int    Delta;
  83.     void (*UpdateStatus)();
  84.     void (*WriteData)();
  85. } SIO_Type;
  86.  
  87. /* Exported Vars */
  88. extern SIO_Type Sio0;
  89. extern SIO_Type Sio1;
  90.  
  91. /* Exported functions */
  92. int sio_init();
  93.  
  94. int sio_readdata8 (SIO_Type *sio);
  95. int sio_readdata16(SIO_Type *sio);
  96. int sio_readdata32(SIO_Type *sio);
  97.  
  98. void sio_writedata8 (SIO_Type *sio, int data);
  99. void sio_writedata16(SIO_Type *sio, int data);
  100. void sio_writedata32(SIO_Type *sio, int data);
  101.  
  102. int sio_async(SIO_Type *sio, char *buf, int len);
  103.  
  104. void sio_control_write(SIO_Type *sio, int data);
  105. void sio_baud_write(SIO_Type *sio, int data);
  106. void sio_mode_write(SIO_Type *sio, int data);
  107.  
  108. #endif